#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int test(const char *mode, const char *powerlevel);

int main(void)
{
	test("0", "");
	test("1", "0");
	return 0;
}

int test(const char *mode, const char *powerlevel)
{
	char AT_CMD[50];
	memset(AT_CMD, '\0', sizeof(AT_CMD));
	strcpy(AT_CMD, "AT+CGREG=");

	if (strcmp(mode, "0") == 0)
	{
		printf("mode = 0\r\n");
		printf("powerlevel = %s\r\n", powerlevel);
		strcat(AT_CMD, mode);
	}
	else if (strcmp(mode,"1") == 0)
	{
		printf("mode = 1\r\n");
		snprintf(AT_CMD + strlen(AT_CMD), 50 - strlen(AT_CMD), "%s,%s", mode, powerlevel);
	}
	else
	{
		printf("ERROR!!!\r\n");
	}

	printf("cmd:%s\r\n", AT_CMD);
}